package com.csun.cmny.provider.ice;

import com.csun.cmny.config.properties.CmnyProperties;
import com.csun.cmny.provider.netty.NettyInitRunner;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.socket.nio.NioDatagramChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

import javax.annotation.Resource;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-08-27 19:59
 * @Description: the class ice server config
 */
@Slf4j
@Order(35)
@Configuration
@ConditionalOnProperty(prefix = "cmny.ice", name = "switch", havingValue = "on")
public class IceServerConfig {

    @Resource
    private CmnyProperties cmnyProperties;
    @Resource
    private IceServerHandler iceServerHandler;

//    @Bean
//    public IceServer iceServer() {
//
//        int port = cmnyProperties.getIce().getPort();
//
//        log.info("### ice init runner starting...<<<<<<<<<<<<<");
//
//        IceServer iceServer =
//                new IceServer(port, null, new Bootstrap(), iceServerHandler);
//
//        iceServer.init();
//
//        NettyInitRunner.nettyServerMap.put(port, iceServer);
//
//        log.info("### ice init runner finish...<<<<<<<<<<<<<");
//
//        return iceServer;
//    }

}
